<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import = "java.sql.Timestamp" %>
<%@ page import = "shop.coffeeshop.master.ShopCoffeeDBBean" %>
<%@ page import = "shop.coffeeshop.master.ShopCoffeeDataBean" %>

<%@ include file="../../etc/color.jspf" %>

<%
String managerId = "";
try{
	managerId = (String)session.getAttribute("managerId");
	if(managerId==null || managerId.equals("")){
		response.sendRedirect("../logon/managerLoginForm.jsp");
	}else{
%>
<%
int coffee_id = Integer.parseInt(request.getParameter("coffee_id"));
String coffee_kind = request.getParameter("coffee_kind");
try{
	ShopCoffeeDBBean coffeeProcess = ShopCoffeeDBBean.getInstance();
	ShopCoffeeDataBean coffee = coffeeProcess.getCoffee(coffee_id);
%>
<html>
<head>
<title>상품수정</title>
<link href="../../etc/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../../etc/script.js">
</script>
</head>
<body bgcolor="<%=bodyback_c%>">
<p>상품 수정</p>
<br>

<form method="post" name="writeform" 
action="coffeeUpdatePro.jsp" enctype="multipart/form-data">
<table>
<tr>
<td align="right" colspan="2" bgcolor="<%=value_c %>">
<a href="../managerMain.jsp">관리자 메인으로</a>&nbsp;
<a href="coffeeList.jsp?coffee_kind=<%=coffee_kind %>">목록으로</a>
</td>
</tr>
<tr>
<td width="100" bgcolor="<%=value_c %>">분류 선택</td>
<td width="400" align="left">
<select name="coffee_kind">

<option value="100"
<%if(coffee.getCoffee_kind().equals("100")){ %>selected<%} %>
>원두</option>

<option value="200"
<%if(coffee.getCoffee_kind().equals("200")){ %>selected<%} %>
>텀블러</option>

<option value="300"
<%if(coffee.getCoffee_kind().equals("300")){ %>selected<%} %>
>기타</option>
</select>
</td>
</tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">제목</td>
<td width="400" align="left">
<input type="text" size="50" maxlength="50" name="coffee_title"
value="<%=coffee.getCoffee_title()%>">
<input type="hidden" name="coffee_id" value="<%=coffee_id %>"></td>
</tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">가격</td>
<td width="400" align="left">
<input type="text" size="10" maxlength="9" name="coffee_price"
value="<%=coffee.getCoffee_price()%>">원</td>
</tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">수량</td>
<td width="400" align="left">
<input type="text" size="10" maxlength="5" name="coffee_count"
value="<%=coffee.getCoffee_count()%>">개</td>
</tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">원산지</td>
<td width="400" align="left">
<input type="text" size="10" maxlength="5" name="author"
value="<%=coffee.getAuthor()%>"></td>
</tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">제조사</td>
<td width="400" align="left">
<input type="text" size="10" maxlength="9" name="publishing_com"
value="<%=coffee.getPublishing_com()%>"></td>
</tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">제조일</td>
<td width="400" align="left">
<select name="publishing_year">
<%
Timestamp nowTime = new Timestamp(System.currentTimeMillis());
int lastYear = Integer.parseInt(nowTime.toString().substring(0,4));
for(int i=lastYear;i>=2010;i--){
%>
<option value="<%=i%>"
<%if(Integer.parseInt(coffee.getPublishing_date().substring(0,4))==i){ %>
selected<%} %>><%=i%></option>
<%} %>
</select>년

<select name="publishing_month">
<%
for(int i=1;i<=12;i++){
%>
<option value="<%=i %>"
<%if (Integer.parseInt(coffee.getPublishing_date().substring(5,7))==i) {%>
selected<%} %>><%=i %></option>
<%} %>
</select>월

<select name="publishing_day">
<%
for(int i=1;i<=31;i++){
%>
<option value="<%=i %>"
<%if (Integer.parseInt(coffee.getPublishing_date().substring(8))==i) {%>
selected<%} %>><%=i %></option>
<%} %>
</select>일

</td>
</tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">이미지</td>
<td width="400" align="left">
<input type="file" name="coffee_image"><%=coffee.getCoffee_image() %></td>
</tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">내용</td>
<td width="400" align="left">
<textarea name="coffee_content" rows="13" cols="40"><%=coffee.getCoffee_content() %></textarea>
</td></tr>

<tr>
<td width="100" bgcolor="<%=value_c%>">할인율</td>
<td width="400" align="left">
<input type="text" size="5" maxlength="2" name="discount_rate"
value="<%=coffee.getDiscount_rate()%>">%</td>
</tr>

<tr>
<td colspan=2 bgcolor="<%=value_c%>" align="center">
<input type="button" value="상품수정" onclick="updateCheckForm(writeform)">
<input type="reset" value="다시 작성">
</td></tr>
</table>
</form>
<%
}catch(Exception e){
	e.printStackTrace();
}
%>
</body>
</html>
<%
	}
}catch(Exception e){
	e.printStackTrace();
}

%>